<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:p="http://primefaces.org/ui" >

	<h:form id="frm1">
		<p:growl id="msgs1" showDetail="true" />
		<p:panel id="contPanel" header="【第一步】基本信息录入【在录入信息后一定要保存后再进行其他后续操作】" style="margin-bottom:5px">		
			<h:panelGrid columns="4" cellspacing="10">		
				<p:commandButton value="新增发货单" icon="ui-icon-plus" 
	           		process="@this" update=":frm1 :frm2:rdt :frmAttach" 
                 	actionListener="#{receiptMB.onAdd}" />	
				<p:commandButton value="保存发货单"	icon="ui-icon-check" 
					action="#{receiptMB.saveAction}" update=":frm1:msgs1">
				</p:commandButton>	
				<p:commandButton value="提交流程"	icon="ui-icon-pencil"  immediate="true"
					action="#{receiptMB.commitWfmAction}"  update=":frm1:msgs1">
				</p:commandButton>
			</h:panelGrid>
			
			<h:panelGrid columns="10" cellspacing="10" >								
		        <p:commandButton id="purchOrderBtn" value="选择订单..."  type="button" icon="fa fa-fw fa-search-plus" 
		        	 onclick="PF('ovpl').loadContents();" />
		        	 
				<p:inputText  value="#{receiptMB.selectedPurchOrder.id}" required="true" disabled="true" 
					placeholder="订单选择..." requiredMessage="订单编号必须输入"/>

				<p:outputLabel value="项目名称" />
				<p:inputText id="pproject" value="#{receiptMB.selectedPurchOrder.bmeContract.pname}"  readonly="true"  disabled="true"/>

				<p:outputLabel value="合同名称" />
				<p:inputText id="pcontract" value="#{receiptMB.io.contName}"  readonly="true"  disabled="true"/>

				<p:outputLabel value="发货单编号" />
				<p:inputText  value="#{receiptMB.io.id}" required="true" requiredMessage="发货单编号必须输入"/>

				<p:outputLabel value="发货日期" />
				<p:calendar id="signDate" locale="zh" navigator="true"  value="#{receiptMB.io.sendDate}" 
					pattern="yyyy-MM-dd" mask="true"  mode="popup"	showOn="button" popupIconOnly="true"
					required="true" requiredMessage="订单日期必须输入" /> 

				<p:outputLabel value="供应商名称" />
				<p:inputText value="#{receiptMB.io.supplier}"  readonly="true"  disabled="true"/>
				<p:outputLabel value="收货地址" />
				<p:inputText value="#{receiptMB.io.address}" />	
				<p:outputLabel value="收货人" />
				<p:inputText value="#{receiptMB.io.consignee}" />	
				<p:outputLabel value="电话" />
				<p:inputText value="#{receiptMB.io.phone}" />	
				<p:outputLabel value="车牌号" />
				<p:inputText value="#{receiptMB.io.lpn}" />	
				<p:outputLabel value="司机及电话" />
				<p:inputText value="#{receiptMB.io.driver}" />	
				
				<p:outputLabel value="单据状态" />
				<p:selectOneMenu value="#{receiptMB.io.status}" effect="fold" style="width:80%;" 
					required="true" requiredMessage="状态必须输入" disabled="true">
					<f:selectItem itemLabel="选择..." itemValue="" noSelectionOption="true"  />
					<f:selectItems value="#{receiptMB.itemsStatus}" />
				</p:selectOneMenu>				
				<p:outputLabel value="备注" />
				<p:inputText value="#{receiptMB.io.remarks}" />	
									
			</h:panelGrid>
				
		</p:panel>

		<!-- 选择采购订单 -->
	    <p:overlayPanel id="purchBtnPanel" for="purchOrderBtn" hideEffect="fade" dynamic="true" 
	   				style="width:720px"  widgetVar="ovpl"  >
	        <p:dataTable var="srow" value="#{receiptMB.bmePurchOrders}"  
	        	paginator="true" paginatorPosition="bottom" emptyMessage="没有记录"
	         	selectionMode="single" selection="#{receiptMB.selectedPurchOrder}" rowKey="#{srow.id}" >
	        
	           <p:ajax event="rowSelect" listener="#{receiptMB.onPurchOrderSelected}" update=":frm1:contPanel :frm2" oncomplete="PF('ovpl').hide();" />
	           <p:column headerText="合同名称" filterBy="#{srow.contName}" filterMatchMode="contains" sortBy="#{srow.contName}">
	               <h:outputText value="#{srow.contName}" />
	           </p:column>

	           <p:column headerText="订单编号" filterBy="#{srow.id}" filterMatchMode="contains">
	               <h:outputText value="#{srow.id}" />
	           </p:column>        
	            <p:column headerText="供应商">
	               <h:outputText value="#{srow.bmeSupplier.name}" />
	           </p:column>
	            <p:column headerText="收货地址">
	               <h:outputText value="#{srow.shippingAddress}" />
	           </p:column>
	            <p:column headerText="收货人">
	               <h:outputText value="#{srow.consignee}" />
	           </p:column>
	            <p:column headerText="电话">
	               <h:outputText value="#{srow.phone}" />
	           </p:column>
	       </p:dataTable> 
	    </p:overlayPanel>		
	</h:form>
	<h:form id="frmAttach" > 	
		<p:growl id="msgsAttach" showDetail="true" />		
		<p:panel id="panelAttached" header="附件信息上传" toggleable="true" toggleSpeed="500" 
			 style="margin-bottom:10px" collapsed="true"> 
			<p:ajax event="toggle" listener="#{attachUploadMB.onToggle}" update="frmAttach" />
			<!-- 页面间参数传递 -->
			<ui:include src="bme_attach_upload.xhtml">
			     <ui:param name="uploadForType" value="#{receiptMB.uploadForType}" />
			     <ui:param name="uploadForId" value="#{receiptMB.uploadForId}" />
			     <ui:param name="uploadForName" value="#{receiptMB.uploadForName}" />
			</ui:include>
        </p:panel>		
	</h:form>

</ui:composition>
